Component({
  options: {
    addGlobalClass: true
  },
  properties: {
    placeholder: {
      type: String,
      value: '请输入'
    },
    inset: Boolean,
    title: String,
    required: Boolean,
    disabled: Boolean,
    readonly: Boolean,
    showLink: Boolean,
    wrap: Boolean,
    type: {
      type: String,
      value: 'text'
    },
    marginBottom: {
      type: String,
      value: '20rpx'
    },
    value: {
      type: null,
      value: ''
    },
    showClearBtn: {
      type: Boolean,
      value: true
    }
  },
  data: {

  },

  methods: {
    onInput(event) {
      this.setData({
        value: event.detail.value
      })

      this.triggerEvent('change', event.detail.value);
    },

    onClear() {
      this.setData({
        value: ''
      });
      this.triggerEvent('change', '');
      this.triggerEvent('clear', '');
    },

    onClick() {
      if (this.data.disabled) return;
      this.triggerEvent('click');
    }
  }
})